Private Sub Workbook_BeforeClose(Cancel As Boolean)

Sheets(1).Visible = 0
Sheets(2).Visible = 0
Sheets(3).Visible = 0
Sheets(4).Visible = 0
Sheets(5).Visible = 0
Sheets(6).Visible = 0
Sheets(7).Visible = 1




End Sub

Private Sub Workbook_Open()
Dim Password, Pword
Password = "123" '自己的密码
Pword = InputBox("请输入密码")
If Pword <> Password Then
MsgBox "没有访问权限"
Sheets(1).Visible = 0
Sheets(2).Visible = 0
Sheets(3).Visible = 0
Sheets(4).Visible = 0
Sheets(5).Visible = 0
Sheets(6).Visible = 0
Sheets(7).Visible = 1
ThisWorkbook.Close
Else
Call 张三1
End If
End Sub

Sub 张三1()

For Each s In Sheets

s.Visible = 1

Next

End Sub
